// ==UserScript==
// @name i139
// @author wgu
// @description  i139
// @include http://js.i139.cn/mamspps/s.do?*
// ==/UserScript==
var i=2,a='',l=document.getElementsByTagName('img')[5].src.indexOf('?');
var con={
	'1':'1','2':'2','3':'3','4':'4'
	,'a':'1','b':'2','c':'3','d':'4'
};
var ac={
	'1234':1
	,'3214':'31'
	,'1243':'34'
	,'1432':'22'
	,'2134':'23'
	,'3241':'34'
	,'3412':'22'
	,'2314':'23'
	,'4213':'31'
	,'1342':'22'
	,'2143':'23'
	,'1423':'34'
	,'4132':'23'
	,'3124':'31'
	,'2431':'22'
	,'4231':'31'
	,'3142':'22'
	,'2341':'23'
	,'3421':'34'
	,'4312':'23'
	,'1324':'31'
	,'2413':'22'
	,'4123':'31'
	,'4321':'31'
}
for(i=2;i<6;i++){
	a+=con[document.getElementsByTagName('img')[i].src[l-5]];
}

if(location.href.indexOf('pid=243&')!=-1){
	document.getElementById('__wmlbrowser_pin').value=ac[a][0];
	document.getElementById('__wmlbrowser_pim').value=ac[a][1];
	alert(1);
}else{
	if(ac[a]==1){
		setTimeout("location.href=document.getElementsByTagName('a')[0].href",3000);	
	}else{
		document.getElementById('__wmlbrowser_pin').value=ac[a][0];
		document.getElementById('__wmlbrowser_pim').value=ac[a][1];
		document.getElementsByTagName('button')[0].click();
	}
}